fix(ts): expose open/openSync/openRemote for NodeNext#324
Merged
ospfranco merged 2 commits intoSep 15, 2025
Merged
Conversation
This was referenced Sep 12, 2025
Contributor
|
Your usage of NodeNext already brought other changes just to make your use-case work... it's getting to the annoying point. I will merge this but on the first pebble I find, I might revert this and just use Bundler as that is the value pure RN/Expo projects use. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
fix(ts): expose open/openSync/openRemote for NodeNext
Problem
moduleResolution: NodeNext,@op-engineering/op-sqlitenamespace and named imports do not expose value exports from./functions(e.g.,open,openSync,openRemote). This produces type errors despite those functions existing at runtime.Symptoms
Goal
open,openSync, andopenRemoteare visible from the package root in TypeScript projects usingmoduleResolution: NodeNext(common in RN/modern ESM), so both namespace and named imports type-check.Blocker
exportsmap. Ourindex.d.tsused:export * from './functions'export { Storage } from './Storage'export * from './types'./functions(e.g.,open/openSync/openRemote), while direct exports likeStoragestill appeared. Runtime ESM was fine; this was a type visibility issue only.Options
export *with explicit named re-exports insrc/index.tsso TypeScript emits concrete named re-exports inindex.d.ts.package.json#exportsfor./functions,./types, and./Storageto help NodeNext resolvers “see” those modules explicitly across TS versions.isIOSEmbeededvsisIOSEmbeddedspelling mismatch without breaking changes by providing a correctly spelled export alongside a deprecated alias.Solution
src/index.tsnow re-exports explicitly:OPSQLite,open,openRemote,openSync,moveAssetsDatabase,getDylibPath,isSQLCipher,isLibsql,isIOSEmbedded, andisIOSEmbeeded.export * from './types'withexport type { ... } from './types'listing all public types to avoid NodeNext elision and ensure types are visible to both namespace and named imports.isIOSEmbeddedand keptisIOSEmbeededas a@deprecatedalias for backward compatibility.Verification
yarn typecheckpasses;yarn prepareregenerates types with named re-exports.import * as Sqlite from '@op-engineering/op-sqlite'thenSqlite.open({ name: 'test.db' })type-checks.import { open } from '@op-engineering/op-sqlite'also type-checks.Notes
Related: Effect-TS/effect#5499 effect-native/effect-native#122